package myJs.myPkg

import org.scalajs.dom.Element
import slinky.readwrite.ObjectOrWritten

import scala.scalajs.js
import scala.scalajs.js.UndefOr
import scala.scalajs.js.annotation.JSImport

/**
 * Created by yz on 2019/3/14
 */
@JSImport("qrcode", JSImport.Namespace)
@js.native
object Qrcode extends js.Object {

  def toCanvas(canvasElement: Element, text: String, cb: js.Function1[js.Any, Unit]): Unit = js.native

  def toDataURL(canvasElement: Element, text: String, cb: js.Function2[UndefOr[String], String, Unit]): Unit = js.native

  def toDataURL(canvasElement: Element, text: String, options: ObjectOrWritten[QrcodeOptions], cb: js.Function2[UndefOr[String], String,
    Unit]): Unit = js.native

  def toDataURL(text: String, options: ObjectOrWritten[QrcodeOptions], cb: js.Function2[UndefOr[String], String,
    Unit]): Unit = js.native

  def `toString`(text: String, cb: js.Function2[UndefOr[String], String, Unit]): Unit = js.native

  def `toString`(text: String, options: ObjectOrWritten[QrcodeOptions], cb: js.Function2[UndefOr[String], String, Unit]): Unit = js.native

}

case class QrcodeOptions(
                          `type`: js.UndefOr[String] = js.undefined,
                          errorCorrectionLevel: js.UndefOr[String] = js.undefined,
                          width: js.UndefOr[Double] = js.undefined,
                        )
